package max.ta.data.plot.data;

public class MathPoint<X extends Comparable<X>, Y>
	implements Comparable<MathPoint<X, Y>> {

    private final X x;
    private final Y y;

    public MathPoint(X x, Y y) {
	super();
	this.x = x;
	this.y = y;
    }

    public X getX() {
	return x;
    }

    public Y getY() {
	return y;
    }

    @Override
    public int compareTo(MathPoint<X, Y> o) {
	return x.compareTo(o.x);
    }

    @Override
    public String toString() {
	return "MathPoint [x=" + x + ", y=" + y + "]";
    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + (x == null ? 0 : x.hashCode());
	result = prime * result + (y == null ? 0 : y.hashCode());
	return result;
    }


    @Override
    @SuppressWarnings("unchecked")
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (obj == null) {
	    return false;
	}
	if (getClass() != obj.getClass()) {
	    return false;
	}
	MathPoint<X, Y> other = (MathPoint<X, Y>) obj;
	if (x == null) {
	    if (other.x != null) {
		return false;
	    }
	} else if (!x.equals(other.x)) {
	    return false;
	}
	if (y == null) {
	    if (other.y != null) {
		return false;
	    }
	} else if (!y.equals(other.y)) {
	    return false;
	}
	return true;
    }
}
